package com.tuananh.radnom.web.controller;

import java.io.IOException;
import java.util.ArrayList;

import org.codehaus.jackson.JsonParseException;
import org.codehaus.jackson.map.JsonMappingException;
import org.codehaus.jackson.map.ObjectMapper;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.tuananh.radnom.model.NetNode;
import com.tuananh.radnom.service.config.INetNodeService;

@Controller
@RequestMapping(value="/ajax/nodeService")
public class NetNodeController {
	public static ABC abc = new ABC();
	{abc.name="TuanAnh";}
	INetNodeService netNodeService;
	@Value("#{netNodeConfigService}")
	public void setNetNodeService(INetNodeService netNodeService) {
		this.netNodeService = netNodeService;
	}
	@RequestMapping(value="/getAll", method = RequestMethod.GET)
	public @ResponseBody ArrayList<NetNode> getAll() {
		return netNodeService.getAll() ;
	}
	@RequestMapping(value="/remove",method = RequestMethod.GET)
	public @ResponseBody boolean remove(@RequestParam String nodeName){
		return netNodeService.remove(nodeName);
	}
	@RequestMapping(value="/update",method=RequestMethod.POST)
	public @ResponseBody boolean update(@RequestBody NetNode node){
		return netNodeService.update(node);
	}
	@RequestMapping(value="/persit",method=RequestMethod.GET)
	public @ResponseBody boolean persit(){
		return netNodeService.persit();
	}
}
